package org.htmlparser.filters;

import org.htmlparser.Node;
import org.htmlparser.NodeFilter;

public class AndFilter
  implements NodeFilter
{
  protected NodeFilter[] mPredicates;

  public AndFilter()
  {
    setPredicates(null);
  }

  public AndFilter(NodeFilter paramNodeFilter1, NodeFilter paramNodeFilter2)
  {
    NodeFilter[] arrayOfNodeFilter = new NodeFilter[2];
    arrayOfNodeFilter[0] = paramNodeFilter1;
    arrayOfNodeFilter[1] = paramNodeFilter2;
    setPredicates(arrayOfNodeFilter);
  }

  public AndFilter(NodeFilter[] paramArrayOfNodeFilter)
  {
    setPredicates(paramArrayOfNodeFilter);
  }

  public boolean accept(Node paramNode)
  {
    int i = 1;
    for (int j = 0; (i != 0) && (j < this.mPredicates.length); ++j)
      if (!(this.mPredicates[j].accept(paramNode)))
        i = 0;
    return i;
  }

  public NodeFilter[] getPredicates()
  {
    return this.mPredicates;
  }

  public void setPredicates(NodeFilter[] paramArrayOfNodeFilter)
  {
    if (paramArrayOfNodeFilter == null)
      paramArrayOfNodeFilter = new NodeFilter[0];
    this.mPredicates = paramArrayOfNodeFilter;
  }
}